package com.justgame.project.service.system.service.basic;

import com.justgame.project.service.system.entity.SysHomeColumn;
import com.justgame.project.service.system.query.SysHomeColumnQuery;
import com.justgame.project.service.system.wrapper.SysHomeColumnWrapper;
import com.justgame.project.base.servcice.IBasicService;
import org.springframework.util.Assert;
import org.springframework.lang.NonNull;
import java.lang.String;

/**
 *
 * 首页菜单栏目配置表服务自定义查询类
 *
 * @@tableName sys_home_column
 * @author Zwb
 */
@SuppressWarnings("all")
public interface BasicSysHomeColumnService extends IBasicService<SysHomeColumnQuery,SysHomeColumn,SysHomeColumnWrapper> {

   /**
    * 新增创建
    * @param title 标题
    * @param logoType 板块类型
    * @param linkPath 链接地址
    * @param description 描述
    */
   default SysHomeColumn baseAdd(String title, SysHomeColumn.LogoType logoType, String linkPath, String description){
      SysHomeColumn sysHomeColumn = new SysHomeColumn();
      sysHomeColumn.setTitle(safeValue(title, null));
      sysHomeColumn.setLogoType(safeValue(logoType, null));
      sysHomeColumn.setLinkPath(safeValue(linkPath, null));
      sysHomeColumn.setDescription(safeValue(description, null));
      save(sysHomeColumn);
      return sysHomeColumn;
   }

   /**
    * 更新
    * @param title 标题
    * @param logoType 板块类型
    * @param linkPath 链接地址
    * @param description 描述
    */
   default boolean baseUpdate(@NonNull SysHomeColumn sysHomeColumn,String title, SysHomeColumn.LogoType logoType, String linkPath, String description){
      Assert.notNull(title,"必须提供标题");
      Assert.notNull(linkPath,"必须提供链接地址");
      Assert.notNull(logoType,"必须提供板块类型");
      Assert.notNull(description,"必须提供描述");
      Assert.notNull(sysHomeColumn.getId(),"必须提供主键ID");
      sysHomeColumn.setTitle(safeValue(title, null));
      sysHomeColumn.setLogoType(safeValue(logoType, null));
      sysHomeColumn.setLinkPath(safeValue(linkPath, null));
      sysHomeColumn.setDescription(safeValue(description, null));
      return updateById(sysHomeColumn);
   }

}